package com.lixinlei.springboot_servlet.controller.hello;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter(filterName = "helloFilter", urlPatterns = "/hello/*")
public class HelloFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        System.out.println("-----------------------HelloFilter.before()");
        resolveRequestParam(request);
        chain.doFilter(request, response);
        System.out.println("-----------------------HelloFilter.after()");
    }

    private void resolveRequestParam(ServletRequest request) {
        String name = request.getParameter("name");
        System.out.println();
    }

    @Override
    public void destroy() {

    }

}
